import { createApp, h, provide } from 'vue';
import { DefaultApolloClient } from '@vue/apollo-composable'
import VueApolloComponents from '@vue/apollo-components'
import App from './App.vue';
import router from '@/router';
import stepin from 'stepin/es';
import '@/mock';
import { createPinia } from 'pinia';
// 生产打包时可去除 ant-design-vue/dist/antd.variable.less 的引用。
// 开发引入此包是为了加载优化，防止首次打开页面过慢
import 'ant-design-vue/dist/antd.variable.less';
import 'ant-design-vue/lib/message/style/index.css'
import 'ant-design-vue/lib/modal/style/index.css'
import 'stepin/es/style';
// import 'default-passive-events';
import '@/theme/index.less';
import { AuthPlugin, IconfontPlugin } from '@/plugins';
import { apolloClient } from './utils/apolloClient';
import { createApolloProvider } from '@vue/apollo-option';

const apolloProvider = createApolloProvider({
  defaultClient: apolloClient,
})

const app = createApp({
  setup() {
    provide(DefaultApolloClient, apolloClient);
  },
  render: () => h(App),
});

app.use(createPinia());
app.use(router);
app.use(stepin, { router });
app.use(AuthPlugin, { action: 'disable' });
app.use(apolloProvider);
app.use(VueApolloComponents);

// iconfont 插件。url为你的 iconfont 图标资源地址（你的iconfont 仓库可获取此地址）
app.use(IconfontPlugin, {
  url: ['//at.alicdn.com/t/c/font_3805284_ulvha6ct7d.js', '//at.alicdn.com/t/c/font_4430217_19gqe4agmcp.js'],
});

app.config.errorHandler = function (err) {
  console.error('未捕获的异常，', err);
};

app.mount('#stepin-app');
